package com.ibeeking.found.id.rest.controller.v1;

import com.ibeeking.found.id.api.common.dto.*;
import com.ibeeking.found.id.rest.service.ISerialNoRuleGenerateService;
import com.ibeeking.found.id.service.common.param.*;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/id/serialNoRule/v1")
public class SerialNoRuleController {

    @Resource
    private ISerialNoRuleGenerateService serialNoRuleGenerateServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "规则列表")
    @GetMapping(value = "/list/{keyCode}")
    public List<SerialNoRuleDTO> serialNoRuleList(@PathVariable("keyCode") String keyCode) {
        return serialNoRuleGenerateServiceImpl.queryByKeyCode(keyCode);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "规则添加")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) SerialNoRuleParam serialNoRuleParam) {
        return serialNoRuleGenerateServiceImpl.add(serialNoRuleParam);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "批量规则添加")
    @PostMapping(value = "/batchAdd")
    public Boolean batchAdd(@RequestBody @Validated(BaseValidationGroup.Insert.class) List<SerialNoRuleParam> serialNoRuleParams) {
        return serialNoRuleGenerateServiceImpl.batchAdd(serialNoRuleParams);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "规则修改")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) SerialNoRuleParam serialNoRuleParam) {
        return serialNoRuleGenerateServiceImpl.modify(serialNoRuleParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "批量规则修改")
    @PostMapping(value = "/batchModify")
    public Boolean batchModify(@RequestBody @Validated(BaseValidationGroup.Update.class) List<SerialNoRuleParam> serialNoRuleParams) {
        return serialNoRuleGenerateServiceImpl.batchModify(serialNoRuleParams);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "规则删除")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return serialNoRuleGenerateServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "规则查看")
    @GetMapping(value = "/view/{id}")
    public SerialNoRuleDTO view(@PathVariable("id") Long id) {
        return serialNoRuleGenerateServiceImpl.queryById(id);
    }
    /*
    * 合同规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存合同规则code")
    @PostMapping(value = "/saveContractSerialNoRule")
    public Boolean saveContractSerialNoRule(@RequestBody @Validated List<ContractSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveContractSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询合同规则code")
    @PostMapping(value = "/queryContractSerialNoRule")
    public List<ContractSerialNoRuleDTO> queryContractSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryContractSerialNoRule();
    }
    /*
     * 订单规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存订单规则code")
    @PostMapping(value = "/saveOrderSerialNoRule")
    public Boolean saveOrderSerialNoRule(@RequestBody @Validated List<OrderSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveOrderSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询订单规则code")
    @PostMapping(value = "/queryOrderSerialNoRule")
    public List<OrderSerialNoRuleDTO> queryOrderSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryOrderSerialNoRule();
    }
    /*
     * 会员卡号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存会员卡号规则code")
    @PostMapping(value = "/saveMemberCardNoRule")
    public Boolean saveMemberCardNoRule(@RequestBody @Validated List<MemberCardNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveMemberCardNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询会员卡号规则code")
    @PostMapping(value = "/queryMemberCardNoRule")
    public List<MemberCardNoRuleDTO> queryMemberCardNoRule() {
        return serialNoRuleGenerateServiceImpl.queryMemberCardNoRule();
    }
    /*
     * 库存入库单号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存库存入库单号规则code")
    @PostMapping(value = "/saveInstockSerialNoRule")
    public Boolean saveInstockSerialNoRule(@RequestBody @Validated List<InstockSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveInstockSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询库存入库单号规则code")
    @PostMapping(value = "/queryInstockSerialNoRule")
    public List<InstockSerialNoRuleDTO> queryInstockSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryInstockSerialNoRule();
    }
    /*
     * 库存出库单号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存库存出库单号规则code")
    @PostMapping(value = "/saveOutstockSerialNoRule")
    public Boolean saveOutstockSerialNoRule(@RequestBody @Validated List<OutstockSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveOutstockSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询库存出库单号规则code")
    @PostMapping(value = "/queryOutstockSerialNoRule")
    public List<OutstockSerialNoRuleDTO> queryOutstockSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryOutstockSerialNoRule();
    }
    /*
     * 库存盘点单号规则code
     */
    @Log(logType = OperateLogTypeEnum.SAVE, describe = "保存盘点单号规则code")
    @PostMapping(value = "/saveInvCheckSerialNoRule")
    public Boolean saveInvCheckSerialNoRule(@RequestBody @Validated List<InvCheckSerialNoRuleParam> params) {
        return serialNoRuleGenerateServiceImpl.saveInvCheckSerialNoRule(params);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "查询盘点单号规则code")
    @PostMapping(value = "/queryInvCheckSerialNoRule")
    public List<InvCheckSerialNoRuleDTO> queryInvCheckSerialNoRule() {
        return serialNoRuleGenerateServiceImpl.queryInvCheckSerialNoRule();
    }

}
